package org.usmile.algorithms.huawei.acm;

import java.util.Scanner;

// https://blog.csdn.net/qq_34465338/article/details/128626402
public class _狼羊过河 {
    private static int x;
    private static int min = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sheep = sc.nextInt();
        int wolf = sc.nextInt();
        x = sc.nextInt();
        dfs(sheep, wolf, 0, 0, 0);
        System.out.println(min == Integer.MAX_VALUE ? 0 : min);
    }

    private static void dfs(int remainSheep, int remainWolf, int shiftSheep, int shiftWolf, int count) {
        if (remainSheep + remainWolf <= x) {
            min = Math.min(min, count + 1);

            return;
        }

        for (int i = 0; i <= remainSheep; i++) {
            for (int j = 0; j <= remainWolf; j++) {
                if (i + j == 0 || i + j > x) {
                    continue;
                }
                if (shiftSheep + i <= shiftWolf + j) {
                    continue;
                }
                if (remainSheep - i != 0 && remainSheep - i <= remainWolf - j) {
                    continue;
                }
                dfs(remainSheep - i, remainWolf - j, shiftSheep + i, shiftWolf + j, count + 1);
            }
        }
    }
}
